@echo off
SETLOCAL EnableExtensions
set EXE_PATH=D:\install\ocr.exe
set HTML_PATH=D:\install\start.html

:: 检查ocr.exe是否运行
tasklist /FI "IMAGENAME eq ocr.exe" 2>NUL | find /I /N "ocr.exe">NUL
if "%ERRORLEVEL%"=="0" (
    echo ocr.exe is running, closing and restarting...
    taskkill /F /IM ocr.exe
    start cmd /k "%EXE_PATH%"
) else (
    echo ocr.exe is not running, starting...
    start cmd /k "%EXE_PATH%"
)

echo 正在启动，大约等待10s～
:: 等待OCR程序启动
timeout /t 10 /nobreak >NUL


:: 打开HTML文件
start "" "%HTML_PATH%"

ENDLOCAL